package com.salton123.soulove.sailfish.video.ui.adapter

import android.text.format.Formatter
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.salton123.soulove.app.R
import com.salton123.soulove.sailfish.db.VideoItem
import com.salton123.soulove.utils.Utils
import com.salton123.utils.ImageLoader

/**
 * User: newSalton@outlook.com
 * Date: 2019/8/4 19:20
 * ModifyTime: 19:20
 * Description:
 */
class VideoSearchAdapter : BaseQuickAdapter<VideoItem, BaseViewHolder>(
    R.layout.adapter_item_video_search
) {

    override fun convert(holder: BaseViewHolder, item: VideoItem) {
        val ivCardContent = holder.getView<ImageView>(R.id.ivThumbnail)
        ImageLoader.loadImage(ivCardContent, item.filePath)
        holder.setText(R.id.tvTitle, item.name)
        holder.setText(
            R.id.tvSubTitle,
            "${Formatter.formatFileSize(holder.itemView.context, item.size)} " +
                Utils.formatTime(item.duration)
        )
    }
}